<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>垫款业务规则表</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">规则名称</div>
                    <div class="field">
                        <input name="ruleNm" id="ruleNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>

                <div class="clearFix"></div>
                <div class="btnsBox">
                    <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                    <span id="clearBtn" class="sq-button sq-button-round">清空</span>
                 </div>
            </div>
        </form>
    </div>
    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null,callback=null;
    var h1='',h2='',h3='';
    $(function () {
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/capital/capAdvRuleInfo/initList.do',
            method: 'get',
            columns: [
                {display: '垫款规则名称', name: 'ruleNm', minWidth: 100, align: 'center', enabledSort: false},
		        //{display: '规则状态  1.开启 0.关闭', name: 'ruleStsCdNm', minWidth: 100, align: 'left', enabledSort: false},
		       {display: '垫款执行时间', minWidth: 120, align: 'center', enabledSort: false,
                    render:function(rowdata,index,value){
                        var h='';
                        if(rowdata.advCycCdNm != null && rowdata.advCycCdNm != '' && rowdata.advTmCdNm != null && rowdata.advTmCdNm != ''){
                            h +=rowdata.advCycCdNm+" "+rowdata.advTmCdNm;
                        }else if(rowdata.advCycCdNm != null && rowdata.advCycCdNm != ''){
                            h +=rowdata.advCycCdNm ;
                        }else if(rowdata.advTmCdNm != null && rowdata.advTmCdNm != ''){
                            h +=rowdata.advTmCdNm ;
                        }
                        h1=h;
                        return h ;
                    }
                },
		       {display: '逾期金额', minWidth: 100, align: 'center', enabledSort: false,
                    render:function(rowdata,index,value){
                        var h = '';
                        if(rowdata.advMinAmt != null && rowdata.advMinAmt != '' && (rowdata.advMaxAmt == null || rowdata.advMaxAmt == '')){
                            h += '>='+rowdata.advMinAmtStr;
                        }else if(rowdata.advMinAmt != null && rowdata.advMinAmt != ''){
                            h += rowdata.advMinAmtStr;
                        }
                        if(rowdata.advMinAmt != null && rowdata.advMinAmt != '' && rowdata.advMaxAmt != null && rowdata.advMaxAmt != ''){
                            h += '~';
                        }
                        if(rowdata.advMaxAmt != null && rowdata.advMaxAmt != '' && (rowdata.advMinAmt == null || rowdata.advMinAmt == '')){
                            h += '<='+rowdata.advMaxAmtStr;
                        }else if(rowdata.advMaxAmt != null && rowdata.advMaxAmt != ''){
                            h += rowdata.advMaxAmtStr;
                        }
                        h2=h;
                        return h;
                    }
                },
		        {display: '逾期天数', minWidth: 50, align: 'center', enabledSort: false,
                    render:function(rowdata,index,value){
                        var h = '';
                        if(rowdata.minOvdDay != null && rowdata.minOvdDay != '' && (rowdata.maxOvdDay == null || rowdata.maxOvdDay == '')){
                            h += '>='+rowdata.minOvdDay;
                        }else if(rowdata.minOvdDay != null && rowdata.minOvdDay != ''){
                            h += rowdata.minOvdDay;
                        }
                        if(rowdata.minOvdDay != null && rowdata.minOvdDay != '' && rowdata.maxOvdDay != null && rowdata.maxOvdDay != ''){
                            h += '~';
                        }
                        if(rowdata.maxOvdDay != null && rowdata.maxOvdDay != '' && (rowdata.minOvdDay == null || rowdata.minOvdDay == '')){
                            h += '<='+rowdata.maxOvdDay;
                        }else if(rowdata.maxOvdDay != null && rowdata.maxOvdDay != ''){
                            h += rowdata.maxOvdDay;
                        }
                        h3=h;
                        return h;
                    }
                },
                {display: '垫款基数', name: 'advBaseCdNm', minWidth: 100, align: 'center', enabledSort: false},
                {display: '垫款颗粒度', name: 'advTypCdNm', minWidth: 100, align: 'center', enabledSort: false},
                {display: '垫款期数', name: 'advPd', minWidth: 50, align: 'center', enabledSort: false},
                {display: '启用状态', width: 100, align: 'center', enabledSort: false,
                    render: function (rowdata, index, value) {
                        if(rowdata.ruleStsCd == '1'){
                            return '已开启';
                         }
                            return '已关闭';
                    }
                },
		        {display: '垫款方式', name: 'isAllAdv', minWidth: 100, align: 'center', enabledSort: false,
                    render:function(rowdata,index,value){
                        if(rowdata.isAllAdv == '1'){
                            return '全垫';
                        }else{
                            return '非全垫';//rowdata.advPd + '期';
                        }
                    }
                },
                {display: '选择', minWidth: 50,
                    render: function (rowdata, rowindex, value){
                        var h='<a onclick="choose(\''+rowdata.ruleNm+'\',\''+rowdata.advBaseCdNm+'\',\''+rowdata.advTypCdNm+'\',\''+rowdata.advPd+'\',\''+rowdata.id+'\');"></i>选择</a>'
                        return h;
                    }
                },
                
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            allowUnSelectRow: true,
            alternatingRow: false
            /* onRenderComplete: function () {
             iframeResize ();
             } */
        });
        grid.setHeight(100);

        $("#searchBar").ligerForm();

        $("#pageloading").hide();


        /* 查询 */
        $("#searchBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            clearLigerForm("searchBar");
        });
        
        callback = function () {
            grid.reload();
        };

      

    });
    function choose(ruleNm,advBaseCdNm,advTypCdNm,advPd,id){
		parent.$("#ruleNm").html(ruleNm);
        parent.$("#advPd").html(advPd);
        parent.$("#advBaseCdNm").html(advBaseCdNm);
        parent.$("#advTypCdNm").html(advTypCdNm);
        
        parent.$("#advCycCdNm").html(h1);
        parent.$("#advMinAmt").html(h2);
        parent.$("#minOvdDay").html(h3);
        
        parent.$("#capAdvRuleInfoId").val(id);
	
    	frameElement.dialog.close();
	}
</script>

</body>
</html>
